<%@ page import="com.biz.conf.Global" %>
<%@ page import="com.biz.model.Singleton.ZkNode" %>
<%@ page import="com.framework.utils.ConfigUtil" %>
<%@ include file="/jsp/taglib.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/plugins/jsTree/style.min.css" rel="stylesheet">

<style>
    .fileInputContainer{
        width: 150px;
        background-size: 100% 100%;
        height: 150px;
        background-repeat: no-repeat;
    }
    .fileInput{
        position: absolute;
        top:30%;
        left:30%;
    }.upload_pic {
         height: 70px;
         width:70px;
         position: relative;
         cursor: pointer;
         color: #ccbe9e;
         background: #fff;
         overflow: hidden;
         display: inline-block;
         *display: inline;
         *zoom: 1;
     }
    .upload_pic input {
        position: absolute;
        height:100%;
        width:100%;
        right: 0;
        top: 0;
        opacity: 0;
        filter: alpha(opacity=0);
        cursor: pointer
    }
    .upload_pic:hover {
        color: #ccbe9e;
        background: #fff;
        text-decoration: none
    }
</style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>表单验证</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm" onsubmit="return  false">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片：</label>
                            <div class="col-sm-8">
                                <%--<div class="fileInputContainer" id="f03" align="center">--%>
                                <input type="hidden" id="picid2" value="${pwxgoodsGroup.icon}" name="pwxgoodsGroup.icon">
                                <div class="dtupload">
                                    <a href="javascript:;" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="upfile2" onChange="uploadFileEidt('upfile2','f03');">
                                        <img  id="f03" src="${pageContext.request.contextPath}/resources/image/logopic1.png" width="100%"  height="100%"/>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" id="groupDiv">
                            <label class="col-sm-3 control-label">分组选择：</label>
                            <div class="col-sm-8">
                                <select id="groupList" data-placeholder="" class="form-control chosen-select"  name="pwxgoodsGroup.pid" class="form-control">
                                    <option selected value="-1">请选择</option>
                                    <c:forEach items="${list}" var="obj">
                                        <option  value="${obj.id}">${obj.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-8">
                                <input type="hidden" id="state" name="pwxgoodsGroup.state" value="${state}">
                                <input type="hidden" id="type" name="pwxgoodsGroup.type" value="${type}">
                                <input type="hidden" id="groupId" name="pwxgoodsGroup.id" value="${pwxgoodsGroup.id}">
                                <input id="name" name="pwxgoodsGroup.name" class="form-control" type="text" value="${pwxgoodsGroup.name}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-8">
                                <input id="note" name="pwxgoodsGroup.note" class="form-control" type="text" value="${pwxgoodsGroup.note}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary"  onclick="doSave()">提交</button>
                                <button id="btn_close"  class="btn btn-primary" type="button">关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/content.min.js?v=1.0.0"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/demo/form-validate-demo.min.js"></script>
    <script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/layer2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ueditor1_4_2-utf8-jsp/ueditor.config.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ueditor1_4_2-utf8-jsp/ueditor.all.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/ueditor1_4_2-utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<script>
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
var picPath='<%=Global.getConfig("OSSURL")%>';
    var id='${id}';
    //1：分组2：标签
    var type='${type}';
    //0：新增1：编辑
    var state='${state}';

    var ppid='${ppid}';
    $(function () {
        if(type=="1"){
            $("#groupDiv").hide();
        }else{
            $("#groupDiv").show();
        }
        var pid='${pwxgoodsGroup.pid}';
        var icon='${pwxgoodsGroup.icon}';
        if(state==0){
            $("#groupList").val("-1");
            if(ppid!=null&&ppid!=''){
                $("#groupList").val(ppid);
            }
        }else{
            $("#f03").attr("src",picPath+icon);
            $("#groupList").val(pid);
        }
    })


    //关闭iframe
    $('#btn_close').click(function(){
        parent.layer.close(index);
    });

    //上传头像
    function uploadFileEidt(obj,pic){
        $.ajaxFileUpload  ({
            url: '${pageContext.request.contextPath}/file/doUploadFile.ac',
            secureuri: false,
            fileElementId: obj,
            dataType: 'json',
            beforeSend: function() {
                //$("#loading").show();
            },
            complete: function() {
                //$("#loading").hide();
            },
            success: function(data, status) {

                var hi=picPath+data.path;
                $("#"+pic).attr("src",hi);
                $("#picid2").attr("value",data.path);
            },
            error: function(data, status, e) {
                alert(e);
            }
        });
    }

    //保存
    function doSave(){
        var path=$("#picid2").val();
        var type=$("#type").val();
        var pid=$("#groupList").val();
        var name=$("#name").val();
//        var note=$("#note").val();
    var flag=true;
    if(path==null||path==undefined||path==''){alert("请上传图片");flag= false;return}
    if(name==null||name==undefined||name==''){alert("请填写名称");flag= false;return}
//    if(note==null||note==undefined||note==''){alert("请填写备注");flag= false;return}
    if(type=="2"&&pid=="-1"){alert("请选择分组");flag= false;return}
        if(flag){
            $.ajax( {
                url:'${pageContext.request.contextPath}/property/doSaveOrUpdateGroupTag.ac',// 跳转到 action
                data:$("#signupForm").serialize(),
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.success==true)
                    {
                        alert("操作成功！");
                        parent.layer.close(index);
//                        window.top.reload();
                    }else
                    {
                        alert(data);
                    }
                },
                error : function() {
                    alert("操作失败！");
                }
            });
        }
    }

</script>

</body>

</html>

